export default {
  data() {
    return {
      iframeURL: ''
    }
  },
  mounted() {
    var that = this
    this.iframe = document.getElementById('iframe')
    this.iframe.onload = function() {
      // iframe加载完毕后 向html传值
      that.postMsg()
    }
  },
  methods: {
    // 向html传值
    postMsg() {
      if (location.pathname === '/mlg-web/') { // 摩洛哥
        this.iframeURL = 'http://182.160.0.111:8808/mlg' + this.url
      } else if (location.pathname === '/jnk-web/') { // 摩洛哥
        this.iframeURL = 'http://182.160.0.111:8808/jnk' + this.url
      } else if (location.pathname === '/mr-web/') { // 摩洛哥
        this.iframeURL = 'http://182.160.0.111:8808/mr' + this.url
      } else if (location.pathname === '/xgjx-web/') { // 测试
        this.iframeURL = 'http://139.159.188.124:8808/xgjx' + this.url
      } else if (location.pathname === '/fa-web/') { // 测试
        this.iframeURL = 'http://139.159.188.124:8808/fa' + this.url
      } else if (location.pathname === '/mw-web/') { // 测试
        this.iframeURL = 'http://139.159.188.124:8808/mw' + this.url
      } else { // 其他
        this.iframeURL = this.$conUrl + this.url
      }
      const params = {
        // url: 'http://14.29.79.10:9530' + this.url, // 测试用
        url: this.iframeURL, // URL
        file: this.file // 调用的文件名(连续通用套打)
      }
      this.iframe.contentWindow.postMessage(params, '*')
    }
  }
}
